package com.weimengchao.core.config;

import com.weimengchao.common.algorithm.SnowflakeManager;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @description: 雪花算法配置
 * @author: 魏孟超
 * @createDate: 2021-10-15 1:05
 */
@Configuration
public class SnowflakeManagerConfig {

    @Value("${snowflake.machineId:0}")
    private Long machineId;
    @Value("${snowflake.dataCenterId:0}")
    private Long dataCenterId;

    @Bean
    public SnowflakeManager snowflakeManager() {
        SnowflakeManager snowflakeManager = new SnowflakeManager(machineId, dataCenterId);
        return snowflakeManager;
    }
}
